package Models;

import java.util.ArrayList;

import Controllers.MainController;

public class MainModel {

	private MainController controller = null;
	 // this ArrayList that represents the observers in the Observer Design Pattern 
	 // A Collection to keep track of all intersections/Noeuds
	 public ArrayList<Intersection> intersections = new ArrayList<Intersection>();
	 
	 public MainModel(){
		 
	 } //end constructor
	 
	 public void setInterfacingController(MainController controller){
		 this.controller = controller;
	 }
	 
	 public void createIntersectionsList(){
		 //get the parsed formated ArrayList , and instentiate dynamically the intersections
		 intersections.add(new Intersection("Intersection2", 1));
		 intersections.add(new Intersection("Intersection4", 0));
	 }
	 
	 /*
	  * Method implemented for testing , i get the request from the view > controller > model
	  * i send the reply Model > Controller > view
	  * we can modify the design to make the Model notify the View, we will see it with the guys
	  */
	 public void printIntersectionsList(){
		   for (int i=0;i < intersections.size();i++)
		    {
		      Intersection inter = (Intersection)intersections.get(i);
		      System.out.println(inter.getID()+" > State: "+inter.getState());
		    }
		   this.controller.TestAction();
	 }
	  
}
